package com.starblink.utils.app

import android.content.Intent
import com.starblink.frame.base.activity.BaseTVMActivity
import com.starblink.utils.app.animator.FadeInAnimatorActivity
import com.starblink.utils.app.databinding.ActivityMainBinding
import com.starblink.utils.app.vm.MainVM
import com.starblink.utils.log.SKLogger
import com.starblink.utils.stroage.SKStorage

class MainActivity : BaseTVMActivity<ActivityMainBinding,MainVM>() {
    override fun initData() {

    }

    override fun initView() {
        viewBinding.btnLog.setOnClickListener {
            SKLogger.d("MainActivity","日志输出")
        }
        viewBinding.btnHttpQuery.setOnClickListener {
            viewModel.reqQuery()
        }
        viewBinding.btnHttpQuery2.setOnClickListener {
            viewModel.reqQuery2()
        }
        viewBinding.btnHttpMutation.setOnClickListener {
            viewModel.reqMutation()
        }
        viewBinding.btnStoreMmkvPut.setOnClickListener {
            SKStorage.put("MMKV-TEST", "MMKV-TEST")
        }
        viewBinding.btnStoreMmkvGet.setOnClickListener {
            val str=SKStorage.getString("MMKV-TEST", "")
            viewBinding.tvContent.text=str
        }
        viewBinding.btnFadeinAnimator.setOnClickListener {
            val intent = Intent(this, FadeInAnimatorActivity::class.java)
            startActivity(intent)
        }
    }

    override fun initObservable() {
        viewModel.testResult.observe(this){
            viewBinding.tvContent.text=it
        }
    }

    override fun initViewBinding(): ActivityMainBinding {
        return ActivityMainBinding.inflate(layoutInflater)
    }
}